<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/pc/jsp/common/common.jsp"%>
<%@ page language="java" import="com.limao.DBDataClass.SysProjectCateDataClass"%>

<%
String cateidStr=request.getParameter("cateid"); 
int cateid=CacheClass.getIntValue(cateidStr);

%>

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <title>众筹列表</title>
    <script>
		$(window).load(function() {
			$("#header").load("pc/header.jsp"); 
			$("#footer").load("pc/footer.jsp"); 
		});
	</script>
</head>
<body  ontouchstart="">
    
    <!--header-->
	<div  id="header"> </div>

    <div style="display:none">
           <font id="P_cateid"><%=cateid%></font><font id="cate_curpage">1</font>
    </div>

    <div class="container jz">
       <div class="clearfix of">
           <div id="leftBanner" class="leftBanner fl bcf of">
                
           		<span onclick="toCateidList(0,1)" target="#rightBanner" id="leftList0" class="pr db <%if(cateid==0){ %>leftBannerCurrent<%}%>">全部<img src="pc/images/arrowLeft.png" class="dib pa"></span>
            <%  List<SysProjectCateDataClass> CateList= WebFunction.getProjectCate();  %>
              <%for(SysProjectCateDataClass tmp:CateList){ 
              	int tmpCateid=CacheClass.getIntValue(tmp.cateid);
              %>
                <span onclick="toCateidList(<%=tmpCateid%>,1)" id="leftList<%=tmpCateid %>" target="#rightBanner" class="pr db <%if(cateid==tmpCateid){ %>leftBannerCurrent<%}%>"><%=tmp.catename%><img src="images/arrowLeft.png" class="dib pa"></span>
              <%} %>
           </div><!--leftBanner-->

           <div id="rightBanner" class="rightBanner fr bcf">
				<!-- 列表 -->
				<div  id="zhongChouListDiv"></div>
				
				<!-- 分页 -->
			    <div class="c9 f12 lh2 tc mgt30 pageBlock">
			    <%--<p id="P_projectid" style="display:hide"><%=projectid%></p>--%>
			    <ul class='db fr of'  id="listPage"></ul>
			    </div>
           </div><!--rightBanner-->
       </div>
    </div><!--container-->

	<!--footer-->
    <div id="footer" class="footer w100 of"></div>
<script>
var cateid=0;
var curpageForProList=1;
var taotalPagesProList=1;
	           		
    function toCateidList(toCateid,curpage){
    
    	if(curpageForProList==0) return;
    
    	
		$.ajax({
            url: "LoginServlet ",
            data: JSON.stringify({m:1510,cateid:toCateid,keyword:'',curpage:curpage}),
            type: 'post',
            dataType: 'json',
            contentType:"application/json;charset=utf-8",
            success: function (data) {
            	console.log(data);
            	if(data['state']==1)
	          	{
	            	var current = $("#leftList"+toCateid);
	            	$('#leftBanner span').removeClass('leftBannerCurrent');
	            	current.addClass('leftBannerCurrent');
	            	
	            	//更新分页
	            	$("#listPage").html('');
	            	curpageForProList=data.curpage*1;
	           		taotalPagesProList=data.total*1;
 	           		
 	           		if(taotalPagesProList>1)
 	           		{
		           		var start=1;
		           		var end=0;
		           		if(curpageForProList-3>1)
		           		{
		           			start=curpageForProList-3;
		           		}
		           		var end=taotalPagesProList*1;
		           		if(curpageForProList+3<taotalPagesProList)
		           		{
		           			end=curpageForProList+3;
		           		}
		           		var ProPageHtml="";
		           		if(curpageForProList!=1)
		           		{   //上一页
		           			ProPageHtml='<li> <a href="javascript:toCateidList('+toCateid+','+(curpageForProList*1-1)+');" class="page-up">&lt;&nbsp;上一页</a></li>';
		           		}
	
		           		for(var i = start;i<end+1;i++)
		           		{  
		           			if(i==curpageForProList) //当前页
		           			{
		           				ProPageHtml=ProPageHtml+'<li><a href="javascript:void(0);" class="active">'+i+'</a></li>';
		           			}
		           			else
		           			{
		           				ProPageHtml=ProPageHtml+'<li><a href="javascript:toCateidList('+toCateid+','+i+');">'+i+'</a></li>';
		           			}
		           		}
		           		if(curpageForProList!=taotalPagesProList)
		           		{   //下一页
		           			ProPageHtml=ProPageHtml+'<li><a href="javascript:toCateidList('+toCateid+','+(curpageForProList*1+1)+');" class="page-down">下一页&nbsp;&gt;</a></li>';
		           		}
		           		
						$("#listPage").html(ProPageHtml);
	            	}
	            	 //数据组装
	            	$("#zhongChouListDiv").html('');
	    			var t=0;
	    			var contentHtml="";
	    			if(data.list==null) return;
					$.each(data.list, function(index, pro) { //遍历对象数组，index是数组的索引号，objVal是遍历的一个对象。
					    var lr="";
						if(index%2==0) 
						{
						    contentHtml= contentHtml+'<div class="w100 of clearfix">';
							lr='fl';
						}
						else 
						       lr='fr';
					   var stocknum=0; 
				       if((pro.limitenum*1.0-pro.supportnum*1.0)>0)
				       {
				          stocknum=pro.limitenum*1.0-pro.supportnum*1.0;
				       } 						       
						       
						contentHtml= contentHtml+'<div class="proSection-list pr of w100 bcf '+lr+'" style="width: 49%;" onclick="window.location.href=\''+baseUrl+'pc/productDetail.jsp?projectid='+pro.projectid+'\'">'+
								        '<div class="proTittle-list pa w100">'+
								            '<div class="of clearfix w100">'+
								                '<span class="fl cf tc f15">'+pro.stateAbout+'</span>'+
								            '</div>'+
								        '</div>'+
								        '<a class="proTittle-listImg db w100 of">'+
								            '<img src="'+imgBaseUrl+pro.projectimage.split(";")[0]+pc_alllist+'" class="db w100 h100">'+
								        '</a>'+
								        '<div class="proTittle-list-block jz">'+
								           ' <a class="proTittle-list-kindName db of clearfix">'+
								               ' <p class="fl c3 f15">'+pro.projectname+'</p>'+
								                '<span class="fr f14 c3 db">'+pro.companyname+'</span>'+
								            '</a>'+
								            '<a class="progress db" style="margin: 5px 0px 5px;"><div class="bar_span" width="100%"></div></a>'+
								            '<a class="proTittle-list-kindDetail db of clearfix">'+
								                '<div class="fl tl" style="width: 42%">'+
								                    '<p class="db f14 c9">￥'+pro.packagepriceAbout+'</p>'+
								                    '<p class="db f13 c9">单价</p>'+
								                '</div>'+
								                '<div class="fl tl" style="width: 32%">'+
								                    '<p class="db f14 c9">'+stocknum+'</p>'+
								                   ' <p class="db f13 c9">库存</p>'+
								                '</div>'+
								                '<div class="fr tl">'+
								                    '<p class="db f14 c9">'+pro.days+'&nbsp;天</p>'+
								                    '<p class="db f13 c9">送vip</p>'+
								                '</div>'+
								            '</a>'+
								        '</div></div>';	
						if(index%2==1)
						{
						    contentHtml=contentHtml+'</div>';
						 }	
								  	
						t++;
					});
					
					if(t%2==1)
					{
					    contentHtml=contentHtml+'</div>';
					 }        	 
	
	            	 
	   
	            	 
					 $("#zhongChouListDiv").html(contentHtml);
	            	// 进度条
	            	$(".bar_span").each(function () {
		                var ress = $(this).attr('width');
		                var len=ress+"%";
		                console.log(len);
		                $(this).animate({
		                    width:len
		                });
	            	});
            	}
            	else
            	{
            		var current = $("#leftList"+toCateid);
	            	$('#leftBanner span').removeClass('leftBannerCurrent');
	            	current.addClass('leftBannerCurrent');
            		layer.alert(data.info);
            	}
 			},
            error: function (data) {
                 return false;
            },
         });
    }

$().ready(function() {
	
    var cateid=$("#P_cateid").html();
    
    toCateidList(cateid,1);

    
  });
  
</script>
</body>
</html>